package com.zhangshuo.patternDesign.composite;

/**
 * Created by shuo.zhang on 2017-10-27.
 *
 * 文件系统中文件的类型
 */
public class File extends AbstractFile {

    public File(String name) {
        super(name);
    }

    public File (String name,AbstractFile parent){
        super(name,parent);
    }

    @Override
    void deleteFile() {
        System.out.println("开始删除文件:"+super.getName());
        //super.getParent().deleteFile(super.getName());
    }

    @Override
    void deleteFile(String name) {
        throw new UnsupportedOperationException("文件不支持此操作");
    }

    @Override
    void addFile(String name) {
        throw new UnsupportedOperationException("文件不支持此操作");
    }

    @Override
    void display(String prefix) {
        if (null == prefix)
            prefix = "";
        System.out.println(prefix + super.getName());
    }

    @Override
    AbstractFile getFile(int index) {
        throw new UnsupportedOperationException("文件不支持此操作");
    }
}
